/*
 * @Description:表单数据
 * @Version: 2.0
 * @Autor: kafei
 * @Date: 2021-12-01 17:16:49
 * @LastEditors: kafei
 * @LastEditTime: 2021-12-09 16:36:28
 */
import { validPhone } from '@/utils/validate'
const checkPhone = (rule, value, callback) => {
  if (value.length === 0) {
    callback(new Error('联系方式不能为空'))
  }
  const result = validPhone(value)
  return result ? callback() : callback(new Error('请输入正确的联系方式'))
}
export const formData = [
  {
    props: 'userName',
    label: '用户名称',
    type: 'el-input',
    config: {
      placeholder: '请输入用户名称',
      clearable: true
    },
    pattern: [
      { required: true, message: '请输入用户名称', trigger: ['blur', 'change'] }
    ]
  },
  {
    props: 'rid',
    label: '所属角色',
    type: 'el-select-options',
    config: {
      placeholder: '请选择所属角色',
      clearable: true,
      options: [],
      filterable: true
    }
    // pattern: [
    //   { required: true, message: '请选择所属角色', trigger: ['blur', 'change'] }
    // ]
  },
  {
    props: 'nickName',
    label: '用户昵称',
    type: 'el-input',
    config: {
      placeholder: '请输入用户昵称',
      clearable: true
    }
  },

  {
    props: 'telphone',
    label: '联系方式',
    type: 'el-input',
    config: {
      placeholder: '请输入联系方式',
      clearable: true
    },
    pattern: [
      { required: true, message: '联系方式不能为空', trigger: ['blur', 'change'] },
      { validator: checkPhone, trigger: ['blur', 'change'] }
    ]
  },
  // {
  //   props: 'status',
  //   label: '状态',
  //   type: 'el-select-options',
  //   config: {
  //     placeholder: '请选择状态',
  //     options: [
  //       { label: '启用', value: '1' },
  //       { label: '未启用', value: '0' }
  //     ]
  //   }
  // },
  {
    props: 'job',
    label: '岗位',
    type: 'el-input',
    config: {
      placeholder: '请输入岗位',
      clearable: true
    }
  },
  {
    props: 'isLeave',
    label: '是否在职',
    type: 'el-select-options',
    config: {
      placeholder: '请选择是否离职',
      options: [
        { label: '是', value: '1' },
        { label: '否', value: '0' }
      ]
    }
  },
  {
    props: 'remarks',
    label: '备注',
    type: 'el-input',
    config: {
      type: 'textarea',
      placeholder: '请输入备注',
      autosize: { minRows: 2, maxRows: 4 },
      maxlength: '200',
      showWordLimit: true
    }
  }

]
